package com.usf.jprovider.schema.model.jmodel.item.field;

import javax.xml.bind.annotation.XmlElement;

import com.usf.jprovider.object.JObjectNode;
import com.usf.jprovider.object.builder.SQLBuilder;
import com.usf.jprovider.object.env.Environment;
import com.usf.jprovider.schema.provider.AbstractProvider;
import com.usf.jprovider.schema.provider.EmptyProvider;

public final class Column extends AbstractField{
	
	@XmlElement protected AbstractProvider provider;
	
	public Column() {
		super();
		provider = new EmptyProvider();
	}
	
	public AbstractProvider getprovider() {
		return provider;
	}
	
	@Override
	protected void _create(Environment env, JObjectNode node) throws Exception {
		node.setValue(provider.create(env, node));
	}
	@Override
	protected boolean _check(Environment env, JObjectNode node) throws Exception {
		typeNode(node, provider.getType());
		boolean val =  provider.check(env, node);
		return val;
	}
	@Override
	protected void _persist(Environment env, JObjectNode node, SQLBuilder builder) throws Exception{
		typeNode(node, provider.getType());
		provider.persist(env, node, builder);
	}
}
